<style>
.item-btn{text-align:center;padding-bottom:15px;}
.item-sbtn{padding:15px 35px 30px 35px;}
.item-sbtn .layui-btn{float: right;}
.item-sbtn .layui-form-label{width:auto;padding-left:0;}
.oshare_info{border: 3px dashed #E6E6E6;display:block;padding:20px 0;text-align:center;font-size:12px;color:#666}
.oshare_info a{color:#1284f6;text-decoration:underline;padding-right:10px}
.upbm_not .upbm_label{color:#999}
.upbm_not .layui-input-block{display:none;}
</style>
<form class="layui-form layui-font14" name="order" action>
<input type="hidden" name="dispute_bh" value="{:shop_bh()}">
<script type="text/javascript">
var maxnum=5,stop=1000,Rsdata;
$.getScript("/static/thinkct/js/plupload.js", function() {
//创建实例的构造方法
uploader = new plupload.Uploader({
				//上传插件初始化选用那种方式的优先级顺序
                runtimes: 'html5,flash,silverlight,html4', 
                // 上传按钮
				browse_button: 'browse', 
                //上传地址
				url: "/upload/", 
			    resize: {width: 900},  
				max_retries: 1,
				//flash文件地址
                flash_swf_url: '/static/thinkct/js/Moxie.swf', 
				//silverlight文件地址
                silverlight_xap_url: '/static/thinkct/js/Moxie.xap', 
                filters: {
					//不允许队列中存在重复文件
					prevent_duplicates : true, 
                    //最大上传文件大小（格式100b, 10kb, 10mb, 1gb）
					max_file_size:'2mb', 
                    //允许文件上传类型
					mime_types: [
                        {title: "图片文件", extensions:'jpg,png,gif'}
                    ]
                },
				//true:ctrl多文件上传, false 单文件上传
                multi_selection: true 
	});
	uploader.init(); 
	//初始化
	//绑定文件添加进队列事件
	uploader.bind('FilesAdded',function(uploader,files){
	var newnum=maxnum-parseInt($('.filelist div').length+$('#FileListing tr').length),flen=files.length,fhtml,vhtml='',ehtml='';
    // 最多上传newmaxnum
	if(flen>newnum){ 
	     layer.alert("<strong>凭证最多能上传"+maxnum+"张</strong>",{icon:2}); 
         uploader.splice(newnum,10000);  
        }
		for(var i = 0; i<=flen; i++){
			//更新UI
			if(i==flen){ 
			 if(ehtml!=''){layer.alert("<strong>以下凭证已传过了，不要重复上传</strong><br>"+ehtml,{icon:0});}
			 if(uploader.files.length>0){
			 $('#pluing').show();
			 $(fhtml).appendTo('#FileListing');
			 $('#pluing u').html(uploader.files.length);
			 }
			 return false;
			}
			// 最多上传newnum
			if(i>=newnum){ 
			continue;
		    }
			fname=files[i].name;
			fid=files[i].id;
			var f5name=$.md5(files[i].size+files[i].lastModifiedDate+files[i].type);
			 vhtml='<tr id="file-' + fid +'"><td>' + fname +'</td><td></td><td align="center"><a onclick=deling("'+fid+'")>取消</a></td></tr>'
			 $(".filelist :checkbox").each(function(){     
	         if($(this).val()==f5name){
             vhtml='';
			 uploader.removeFile(fid);
			 ehtml+="【"+fname+"】<br>";
			 return false;
			 }
	         });
             fhtml=fhtml+vhtml;	
		}

	});
	uploader.bind("BeforeUpload",function(uploader,file){
    uploader.setOption("multipart_params",{lastDate:file.lastModifiedDate,osize:file.size,number:'{$data.number}',filebh:'155006964878',type:'dispute',filetype:'files',maxnum:maxnum}); 
    }); 
	//进度
	uploader.bind("UploadProgress",function(uploader,file){
	$('#progress-in').width(uploader.total.percent+"%"); 
	$("#file-"+file.id+" td:eq(2)").html("<b>"+file.percent+"%</b>");
    });
	//上传完成后
	uploader.bind("FileUploaded",function(uploader, file,info){
		 $('#progress-uploaded').html(uploader.total.uploaded);
		 var data =$.parseJSON(info.response);
		 if(data.state!=0){
         $fh=$('#progress ul');
         $fh.show();
		 $('<p><span>'+file.name+'</span><br><b>'+data.state+' >> 继续执行…</b></p>').appendTo($fh);
	     stop=3000;
		 }
    });
	//全部完成后
	uploader.bind("UploadComplete",function(uploader){
		setTimeout("Rs(Rsdata)",stop);
    });
	//错误提示
	uploader.bind("Error",function(uploader,err){
		 if(err.message=='HTTP Error.'){
		 fid=err.file.id;
		 $("#file-"+fid+" td:eq(1)").html("<font color=red>系统出错，代码"+err.code+"</font>");
		 $("#file-"+fid+" td:eq(2)").html('<a onclick=deling("'+fid+'")>删除</a>');
		 return false;
		 }
		 layer.alert("<strong>"+err.message+"</strong>",{icon:5});
    });

});
</script>
<div class='notes'>
<li><h3>小提示：</h3></li>
<li><b>1.</b>申请退款后，卖方将收到您的退款申请提醒信息；</li>
<li><b>2.</b>卖方可在3天内对您的退款申请作回应操作（同意/拒绝）；</li>
<li><b>3.</b>若卖方迟迟未作回应处理，3天后系统自动执行退款于您；</li>
<li><b>4.</b>退款前请保留：商品运行（搭建）的效果、聊天记录等证据；</li>
<li><b>5.</b>若无实质性的证据，卖家拒绝退款后，速知站将无法介入处理。</li>
<li><b>6.</b>因交易纠纷原因凭证会永久存档，请双方注意文明用语！</li>
</div>
<div class="layui-form-item">
	<div class="layui-form-label" style='width:auto;'>
		退款金额
	</div>
	<div class="layui-inline">
			<div class="layui-inline" style='margin-right:0;'>
				<input type="radio" checked name="backtype" lay-filter="backtype" value="full" title="全额退款"/>
				<input type="radio"  name="backtype" lay-filter="backtype" value="part" title="部分退款"/>
			</div>
			<div class="layui-inline backmoney_box" style="margin:0;display:none;">
				<div class="layui-inline">
					<input name="backmoney" class="layui-input" value="" maxlength="{$row.money1}" style='width:65px;' lay-verify="backmoney" type="text" />
				</div>
				<div class="layui-inline" style='margin-right:0;'>
					<div class="layui-form-mid layui-word-aux"> 元 （小于{$row.money1}元）</div>
				</div>
			</div>
	</div>
</div>
<div class="layui-form-item">
    <div class="layui-form-label" style='width:auto;'>
	退款主因
	</div>
	<div class='layui-inline'>
		<div class="layui-inline" style='width:103px;'>

	<select lay-verify="required" name='main_reason' lay-filter="main_reason">
		<option value="">请选择..</option>
		<option value="货不对版">货不对版（实际商品与描述不符）</option>
		<option value="质量缺陷">功能缺陷（存在无法使用或缺失的功能）</option>
		<option value="违背承诺">违背承诺（与双方交易前商定的不一致）</option>
		<option value="网盘失效">网盘失效（自动发货的下载链接失效）</option>
		<option value="协商退款">协商退款（与对方达成一致协商退款）</option>
		<option value="其他">其他原因（如质量方面硬性常规问题）</option>

	</select>
</div>
	<div class="layui-inline" style='margin-right:0;'>
					<div class="layui-form-mid layui-word-aux"></div>
				</div>
	</div>
</div>

<div class="layui-form-item">
<div class="upload-box" style='margin:0 15px'>
<p>
<textarea name="txt" class="layui-textarea" lay-verify="reason_txt" style='height:100px;width:96%;margin:10px 2% 0 2%' placeholder="请详细说明申请退款原因，不能少于10个字！"></textarea>
</p>

	<div class="container">
				<div class="statusBar" style='line-height:36px;'>
				<div class="info"><b>1.</b>凭证非必传！限传5个,单个大小限2M，JPG/GIF/PNG格式</div>
					<div class="btns">
					<a id="browse">上传凭证</a>
					</div>
				</div>
<table  class="fu_list" id='pluing' style='display:none;' >
            <thead>
              <tr>
                <td width="65%">待传队列（<u>0</u>）</td>
				<td width="25%" align="center"></td>
                <td width="10%" align="center">操作</td>
              </tr>
            </thead>
            <tbody id="FileListing">
            </tbody>
          </table>
	</div>
</div>
</div>
<div class="layui-form-item item-btn">
    <input type="button" class="layui-btn layui-btn-danger lay-submit" lay-submit="" lay-filter="main" value="申请退款" />
</div>
<input type="hidden" name="layer" value="1">
<input type="hidden" name="role" value="buy">
<input type="hidden" name="utime" value="">
<input type="hidden" name="action" value="apply_back">
<input type="hidden" name="number" value="{$data.number}">
</form>

<script type="text/javascript">
var zindex=parent.layer.zIndex;//当前层INDEX
layer.title('<font color=red style="font-weight:700;font-size:14px;">申请退款</font>');
 layui.use('form', function(){
 var form = layui.form();
 form.verify({
	 	reason_txt: function(value) {
			if($.trim(value).length<10)  return '原因不能少于10个字！';
		}
		,backmoney: function(value) {
			if($("input[name=backtype]:checked").val() == 'part'){
				if(isNaN(value)) return '【部分退款】额度有误，请重新输入！';
				if(value>{$row.money1}) return '【部分退款】额度必须小于交易额：<?
// +----------------------------------------------------------------------
// | ThinkCt框架[基于ThinkPHP6.0开发]
// +----------------------------------------------------------------------
// | Copyright (c) 2020-2021 http://www.thinkct.net
// +----------------------------------------------------------------------
// | ThinkCt承诺基础框架商业版永久免费技术支持，您可用于学习和商用，但必须保留软件版权信息。
// +----------------------------------------------------------------------
// | Author: 时光网络 <66983239@qq.com>，开发者QQ群：61162800 付费QQ群：250059867
// +----------------------------------------------------------------------=$row['money1']?>';
				if(value<=0) return '【部分退款】额度必须大于0';
			}
			if($("input[name=upbm]:checked").val()==1){
				if($("input[name=backtype]:checked").val() == 'part'){
					if(value*1==0) return '退款金额没有任何改动<br>若不修改请不要勾选【修改退款金额】';
				}else{
					if(0==0) return '退款金额没有任何改动<br>若不修改请不要勾选【修改退款金额】';	 
				}
			}
		}

});
form.on('submit(main)', function(data) {
layer.confirm("确定要提交<b class=red> 申请退款 </b>吗？",{icon:3}, function(index){
	layer.load();
	dform(data.field,'order',function(datas){
		if(datas.state==1 && uploader.total.queued>0){
			Rsdata=datas;
			progress();
			$('#progress-upload').html(uploader.total.queued);
			uploader.start();
		}else{
			Rs(datas);
		}
	});
});
return false;
});

form.on('checkbox(upbm)',function(data){
		var $div=$(data.elem).closest(".layui-form-item");
		if(data.elem.checked){
			$div.removeClass("upbm_not");
			$('.layui-textarea').attr('placeholder','请说明修改退款金额原因，不能少于10个字！');
			$('.lay-submit').val('确认修改');
		}else{
			$div.addClass("upbm_not");
			$('.layui-textarea').attr('placeholder','请说明申请退款原因，不能少于10个字！');
			$('.lay-submit').val('确认补充');
		}
});

form.on('radio(backtype)',function(data){
		var $div=$(data.elem).closest(".layui-form-item").find('.backmoney_box');
		if(data.elem.value=='part'){
			$div.show();
		}else{
			$div.hide();
		}
});
form.on('radio(cashed_type)',function(data){
	    $('.layui-btn-cashed').val($(data.elem).data('title'));
	    $('.cashed_box').hide();
		$('.cashed_box_'+data.value).show();
});

form.on('select(main_reason)',function(data){
		$(data.elem).closest(".layui-form-item").find('.layui-form-mid').html(data.elem.value=='网盘失效'?'注：如果您不需要了，请在下方明确告知卖家不要再发货！':'');
});

	form.render(); //更新全部
$('.upbm_label').click(function(){$(this).prev().click();form.render('checkbox')});
});
 document.onkeydown = function(event) {
        var target, code, tag;
        if (!event) {
            event = window.event; //针对ie浏览器
            target = event.srcElement;
            code = event.keyCode;
            if (code == 13) {
                tag = target.tagName;
                if (tag == "TEXTAREA") { return true; }
                else { return false; }
            }
        }
        else {
            target = event.target; //针对遵循w3c标准的浏览器，如Firefox
            code = event.keyCode;
            if (code == 13) {
                tag = target.tagName;
                if (tag == "INPUT") { return false; }
                else { return true; }
            }
        }
    };
if(typeof revise_money == 'function') revise_money();

</script>